<h2>Run HelloWorld using Gradle</h2>

<p>
    Similar to Maven, we can declare the required JavaFX modules in the <kbd>build.gradle</kbd> file.
    However, for Gradle we need to apply the JavaFX gradle plugin:
</p>

<pre><code>
plugins {
  id 'application'
  id 'org.openjfx.javafxplugin' version '<span class="JFX_PLUGIN_VERSION">0.0.5</span>'
}
</code></pre>

<p>
    Next, we add the required modules. For instance, if we only need the <kbd>javafx.controls</kbd> 
    module, we will include:
</p>

<pre><code>
javafx {
    version = "<span class="JFX_VERSION">12</span>"
    modules = [ 'javafx.controls' ]
}
</code></pre>

<p>
    <b>Important</b>: Note that transitive dependencies are automatically resolved
    (for instance, there is no need to add a dependency for the <kbd>javafx.graphics</kbd> module, since it is
    <a href="https://openjfx.io/javadoc/15/javafx.controls/module-summary.html" target="_blank">transitively</a> resolved by the
    <kbd>javafx.controls</kbd> module). But if your application is using <kbd>FXML</kbd>, you will need to
    add the <kbd>javafx.fxml</kbd> module as well.
</p>

<p>
    You can specify a distinct version of JavaFX. For example, if you want to stick to JavaFX 11.0.2:
</p>

<pre><code>
javafx {
    version = "11.0.2"
    modules = [ 'javafx.controls' ]
}
</code></pre>

<p>
    Here is a <a class="samples" href="https://github.com/openjfx/samples/blob/master/HelloFX/Gradle/hellofx/build.gradle" target="_blank">build.gradle</a> 
    file which shows how to achieve this, taken from 
    this <a class="samples" href="https://github.com/openjfx/samples/blob/master/HelloFX/Gradle" target="_blank">sample</a>.
</p>
<p>
    Run the application (e.g. use <a class="samples" href="https://github.com/openjfx/samples/blob/master/HelloFX/Gradle/hellofx/src/main/java/HelloFX.java" target="_blank">HelloFX.java</a> 
    from the given sample) using:
</p>

<ul class="nav nav-tabs">
    <li class="nav-item">
        <a class="nav-link active" href="#nix-grad" data-toggle="tab">Linux/Mac</a>
    </li>
    <li class="nav-item">
        <a class="nav-link" href="#win-grad" data-toggle="tab">Windows</a>
    </li>
</ul>

<div class="tab-content">
    <div class="tab-pane active" id="nix-grad">
<pre class="no-border-radius"><code>
./gradlew run
</code></pre>
    </div>
    <div class="tab-pane" id="win-grad">
<pre><code>
gradlew run
</code></pre>
    </div>
</div>

<div class="alert alert-warning">
    <strong>Note: </strong>
    Our recommendation for the minimum Gradle version against each JDK is as follows:

    <table class="jdk-gradle-version">
        <tr>
            <th>JDK version</th>
            <td>11</td>
            <td>12</td>
            <td>13</td>
            <td>14</td>
            <td>15</td>
        </tr>
        <tr>
            <th>Gradle Version</th>
            <td>5.0</td>
            <td>5.0</td>
            <td>6.0</td>
            <td>6.3</td>
            <td>6.3</td>
        </tr>
    </table>
</div>
